<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>0</h1>
<h2>0</h2>

<script>
    let count=0;
    let count2=0;
    //开启定时器
    setInterval(function f() {
        count++;
        let h1=document.querySelector("h1");
        h1.innerText=count;
    },60000);

    function f() {
        count2++;
        let h2=document.querySelector("h2");
        h2.innerText=count2;
        if(count2==10){
            //停止定时器
            clearInterval(timer);
        }
    }
    //当方法作为参数传递时,()不写
    let timer=setInterval(f,1000);

    //开启只执行一次的定时器
    //当弹出窗口提示时,页面停止渲染,但后台还在运行
    setTimeout(function () {
        alert("执行时间");
    },3000)



</script>
</body>
</html>